﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace demo_ver2
{
    public partial class OfficeControl : UserControl
    {
        public OfficeControl()
        {
            InitializeComponent();           
        }

        public void open(string filename, string mode)
        {
            this.axEDOffice1.Open(filename, mode);
        }

        public void Protect()
        {
            if (axEDOffice1.GetCurrentProgID() == "Word.Application")
            {
                axEDOffice1.ProtectDoc(2);
            }
            else if (axEDOffice1.GetCurrentProgID() == "Excel.Application")
            {
                axEDOffice1.ProtectDoc(1);
            }
            else if (axEDOffice1.GetCurrentProgID() == "PowerPoint.Application")
            {
                axEDOffice1.SlideShowPlay(true);
            }
        }

        public void close()
        {
            this.axEDOffice1.ExitOfficeApp();
        }
    }
}
